/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package camel.server.session;

import camel.server.admin.TeamMember;

import java.awt.Color;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Temporal;

/**
 *
 * @author mac
 */
@Entity
@NamedQueries ( {
	@NamedQuery(name = "findAllCursorOfAMember", query = "SELECT c FROM ParticipantCursor c WHERE c.memberAccount = :member")
})
public class ParticipantCursor implements Serializable {
    
    /**
	 * 
	 */
	private static final long serialVersionUID = -8186915390605330131L;
	private Long id;
    private CollaborationSession session;
    
    private TeamMember memberAccount;
    
    private long lastReceivedCmdId = -1;
    private long lastPostedCmdId = -1;
    private boolean isFacilitator = false;
    private String recentActivity;
    
	private Date timeCreated = new Date();
    private Long lastHeartbeat;
    private boolean sessionPlayback = false;
    private boolean activeInSession = false;
    
    Color color;
    
    public void setId(Long id) {
        this.id = id;
    }

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    public Long getId() {
        return id;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ParticipantCursor)) {
            return false;
        }
        ParticipantCursor other = (ParticipantCursor) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "camel.server.session.ParticipantCursor[id=" + id + "]";
    }

    @ManyToOne
    public CollaborationSession getSession() {
        return session;
    }

    public void setSession(CollaborationSession session) {
        this.session = session;
    }

    @ManyToOne
    public TeamMember getMemberAccount() {
        return memberAccount;
    }

    public void setMemberAccount(TeamMember member) {
        this.memberAccount = member;
    }

    public long getLastReceivedCmdId() {
        return lastReceivedCmdId;
    }

    public void setLastReceivedCmdId(long lastReceivedCmdId) {
        this.lastReceivedCmdId = lastReceivedCmdId;
    }

    public long getLastPostedCmdId() {
        return lastPostedCmdId;
    }

    public void setLastPostedCmdId(long lastPostedCmdId) {
        this.lastPostedCmdId = lastPostedCmdId;
    }

	public boolean isFacilitator() {
		return isFacilitator;
	}

	public void setFacilitator(boolean isFacilitator) {
		this.isFacilitator = isFacilitator;
	}

	public Color getColor() {
		return color;
	}

	public void setColor(Color color) {
		this.color = color;
	}

	public String getRecentActivity() {
		return recentActivity;
	}

	public void setRecentActivity(String recentActivity) {
		this.recentActivity = recentActivity;
	}

	@Temporal(javax.persistence.TemporalType.TIMESTAMP)
	public Date getTimeCreated() {
		return timeCreated;
	}

	public void setTimeCreated(Date timeCreated) {
		this.timeCreated = timeCreated;
	}

	public Long getLastHeartbeat() {
		return lastHeartbeat;
	}

	public void setLastHeartbeat(Long lastHeartbeat) {
		this.lastHeartbeat = lastHeartbeat;
	}

	public void setActiveInSession(boolean activeInSession) {
		this.activeInSession = activeInSession;
	}

	public boolean isActiveInSession() {
		return activeInSession;
	}

	public void setSessionPlayback(boolean sessionPlayback) {
		this.sessionPlayback = sessionPlayback;
	}

	public boolean isSessionPlayback() {
		return sessionPlayback;
	}

}
